package com.listener.direct.config;

import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <h3>springboot_rabbitmq_listener</h3>
 * <p></p>
 *
 * @author gdw
 * @since 2024-07-23 09:43:39
 */
@Configuration
public class DirectConfig {
    @Bean
    public Queue directQueue() {
        return new Queue("object.queue");
    }
    @Bean
    public MessageConverter messageConverter(){
        //1.定义消息转换器
        Jackson2JsonMessageConverter jackson2JsonMessageConverter=new Jackson2JsonMessageConverter();
        //2.配置自动创建消息id,用于识别不同消息,也可以在业务中基于id判断是否是重复的消息
        jackson2JsonMessageConverter.setCreateMessageIds(true);
        return jackson2JsonMessageConverter;
    }
}
